$(function(){
	var date=new Date;
	var year=date.getFullYear(); 
	var month=date.getMonth()+1;
	month =(month<10 ? "0"+month:month); 
	
	$('#startYear').combobox('setValue', year);
	$('#startMonth').combobox('setValue', month);
	$('#endYear').combobox('setValue', year);
	$('#endMonth').combobox('setValue', month);
	
	$('#tt').datagrid({
		url:'/searchData/getNewTaskPageMonthList'
	});
	
});

function checkSearch(){
	var startYear = $("#startYear").combobox('getValue');
	var startMonth = $("#startMonth").combobox('getValue');
	var endYear = $("#endYear").combobox('getValue');
	var endMonth = $("#endMonth").combobox('getValue');
	
	if (startYear != "" || startMonth != "") {
		if (startMonth == "") {
			$.messager.alert("提示", "月份选择有误！");
			return false;
		}
		if (startYear == "") {
			$.messager.alert("提示", "月份选择有误！");
			return false;
		}
	}
	
	if (endYear != "" || endMonth != "") {
		if (endMonth == "") {
			$.messager.alert("提示", "月份选择有误！");
			return false;
		}
		if (endYear == "") {
			$.messager.alert("提示", "月份选择有误！");
			return false;
		}
	}
}

function doSearch(){
	
	checkSearch();
	
	var mark=$('#mark').val();
	var appName=$('#apkName').val();
	var channelName=$('#channelName').val();
	var sysVer=$('#sysVer').combobox('getValue');
	var startYear = $("#startYear").combobox('getValue');
	var startMonth = $("#startMonth").combobox('getValue');
	var endYear = $("#endYear").combobox('getValue');
	var endMonth = $("#endMonth").combobox('getValue');
	var start;
	var end;
	if (startYear != "" && startMonth != "") {
		start = startYear + "-" + startMonth;
	}
	if (endYear != "" && endMonth != "") {
		end = endYear + "-" + endMonth;
	}
	
	
	$('#tt').datagrid({
		queryParams:{
			mark:mark,
			appName:appName,
			channelName:channelName,
			sysVer:sysVer,
			start:start,
			end:end
		}
	});
	
	$('#tt').datagrid('unselectAll');
}

function sortInfo(a,b){
	var number1 = parseFloat(a);  
	var number2 = parseFloat(b);	   
	return (number1 > number2 ? 1 : -1);    
}